package com.gz.purchase.library.pojo;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * 库房实体类
 * author wanner1991
 */
public class StorageRoomInfo extends CustomerSpinnerObject {
    private int storage_id;
    private String storage_name;

    public int getStorage_id() {
        return storage_id;
    }

    public void setStorage_id(int storage_id) {
        this.storage_id = storage_id;
    }

    public String getStorage_name() {
        return storage_name;
    }

    public void setStorage_name(String storage_name) {
        this.storage_name = storage_name;
    }

    public static List<StorageRoomInfo> parse(JSONArray jsonArray) throws JSONException {
        if (jsonArray.length() <= 0 || jsonArray == null){
            return null;
        }
        List<StorageRoomInfo> list = new ArrayList<StorageRoomInfo>();
        StorageRoomInfo info ;
        JSONObject object;
        for (int i = 0 ; i < jsonArray.length() ; i++){
            object = jsonArray.getJSONObject(i);
            info = new StorageRoomInfo();
            info.storage_id = object.getInt("storage_id");
            info.storage_name = object.getString("storage_name");
            list.add(info);
        }
        return list;
    }

    @Override
    public String toString() {
        return storage_name;
    }
}
